﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using Kooboo.HtmlFunc.Function;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.HtmlFunc.Analysis.Visitors
{
    public class ListItemEditableVisitor : VisitorBase
    {
        public ListItemEditableVisitor(VisitorContext context)
            : base(context, FuncType.ListItemEditable)
        {
            this.AttributeName = this.Func.StartComment;
        }

        public string AttributeName
        {
            get;
            private set;
        }

        public override void VisitAttribute(HtmlAttribute attribute)
        {
            if (this.ValidateRule() &&
                this.AttributeName.IgnoreCaseEquals(attribute.Name))
            {
                var list = this.Context.Items[FuncType.List] as IList;
                list.EditableAttribute = attribute;
            }
        }

        protected override FuncType RequireType
        {
            get
            {
                return FuncType.ListItem;
            }
        }
    }
}
